<?php

class Application_Model_CostPrice extends Application_Model_DomainObject {

    protected $_id;
    protected $_agentid;//发货渠道
    protected $_crDatetime; //创建日期
    protected $_channelNo; //物流单号
    protected $_num; // 件数
    protected $_weight; //实重
    protected $_bagweight;//材重
    protected $_channel;  //渠道 
    protected $_destination; //目的地 
    protected $_name; //品名
    protected $_money; //成本价
    protected $_currency; //币种
    protected $_remark; //备注' 

    public static function byMaxTime($agentid)
    {
        $where[" agentid = "] = $agentid;
        $result =  self::getDao()->queryAll($where," crDatetime desc limit 1");
        if(count($result)==0){
            return  "2013-04-01";
        } else {
			// return  "2013-01-01";
            $maxtime = $result[0]->crDatetime;
            return date('Y-m-d',strtotime("$maxtime -4 day"));
        }
    }
   public function getSingleInfo()
   {
        if($this->_channelNo)
        {
            $single = new  Application_Model_Single();
            $where = array();
            $where['outstoreno'] = $this->_channelNo;
            $one = $single->queryOne($where);
            if($one != null){
                return Application_Model_Single::load($one->id);
            }
        }
    }
    
    
    public static function byCostPrice($agentno)
    {
        $where[" channelNo = "] = $agentno;
        return self::getDao()->queryOne($where);
    }
}


